xen: Move tsc reliability check until after CPUs have booted
authorGeorge Dunlap <george.dunlap@eu.citrix.com>
Sat, 17 Sep 2011 15:22:54 +0000 (16:22 +0100)
committerGeorge Dunlap <george.dunlap@eu.citrix.com>
Sat, 17 Sep 2011 15:22:54 +0000 (16:22 +0100)
AMD CPUs by default enable X86_FEATURE_TSC_RELIABLE, and depend upon a
later check to disable this feature if TSC drift is detected.
Unfortunately, this check is done in time.c:init_xen_time(), which is
done before any secondary CPUs are brought up, and is thus guaranteed
to succed.

This patch moves the check into its own function, and calls it after
cpus are brought up.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
xen/arch/x86/setup.c
xen/arch/x86/time.c
xen/include/xen/time.h

index 83d59025d128b908370c44479ace0a5dc7de82fd..5e455668709121c2a6916f1a0b068e1a0f59db89 100644 (file)
@@ -1292,8 +1292,11 @@ void __init __start_xen(unsigned long mbi_p)
     printk("Brought up %ld CPUs\n", (long)num_online_cpus());
     smp_cpus_done();
 
+    verify_tsc_reliability();
+
     do_initcalls();
 
+
     if ( opt_watchdog ) 
         watchdog_setup();
 
index 26388205d43e1bcd689d0e72303fc25647da7c9b..61320c4900f98aa7393269a6dacf7221570fc0ca 100644 (file)
@@ -1450,8 +1450,8 @@ static void __init tsc_check_writability(void)
     disable_tsc_sync = 1;
 }
 
-/* Late init function (after interrupts are enabled). */
-int __init init_xen_time(void)
+/* Late init function, after all cpus have booted */
+void __init verify_tsc_reliability(void)
 {
     if ( boot_cpu_has(X86_FEATURE_TSC_RELIABLE) )
     {
@@ -1463,9 +1463,17 @@ int __init init_xen_time(void)
          */
         tsc_check_reliability();
         if ( tsc_max_warp )
+        {
+            printk("%s: TSC warp detected, disabling TSC_RELIABLE\n",
+                   __func__);
             setup_clear_cpu_cap(X86_FEATURE_TSC_RELIABLE);
+        }
     }
+}
 
+/* Late init function (after interrupts are enabled). */
+int __init init_xen_time(void)
+{
     tsc_check_writability();
 
     /* If we have constant-rate TSCs then scale factor can be shared. */
index a19434079ccbb47c96bab92f2349c4834328f849..068c74215698f7a631bd369fa9115bf53f3f1e0c 100644 (file)
@@ -11,6 +11,7 @@
 #include <xen/types.h>
 #include <public/xen.h>
 
+extern void verify_tsc_reliability(void);
 extern int init_xen_time(void);
 extern void cstate_restore_tsc(void);